<template>
	<view>
		<u-sticky bgColor="#fff">
			<u-tabs :list="tab" lineColor="#1792ff" :activeStyle="{color:'#1792ff'}" :is-scroll="false"
				:scrollable="false" :current="current" @change="_change"></u-tabs>
		</u-sticky>
		<view class="data_info_box">
			<block v-if="data !== undefined && data!== null && data.length>0">
				<view class="data_info_list" v-for="(item ,index) in data" :key="index"
					@click="data_detailed(item.id, item.name)">
					<view class="data_info">
						<view class="data_info_tit">
							<view class="tit">
								<h3>{{item.name}}</h3>
							</view>
						</view>
						<view class="data_info_end">
							<text>{{item.day_date}} (台)</text>
							<view class="border_box">
								<text class="blue_y">{{item.day_total}}</text>
								<view class="">
									<text class="gray_y">{{item.day_hb}}%</text>
									<u-icon v-if="item.day_hb_type == 1" name="../../../static/go_up.png"
										size="24"></u-icon>
									<u-icon v-else name="../../../static/descend.png" size="24"></u-icon>
								</view>
							</view>
						</view>
						<view class="data_info_end">
							<text>当月 (台)</text>
							<view class="border_box">
								<text class="blue_y">{{item.month_total}}</text>
								<view class="">
									<text class="gray_y">{{item.month_hb}}%</text>
									<u-icon v-if="item.month_hb_type == 1" name="../../../static/go_up.png"
										size="24"></u-icon>
									<u-icon v-else name="../../../static/descend.png" size="24"></u-icon>
								</view>
							</view>
						</view>
					</view>
				</view>
			</block>
			<u-empty v-else mode="data" icon="/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tab: [{
						name: '我的',
						type: 1
					},
					{
						name: '团队',
						type: 2
					}
				],
				data: [],
				type: 1,
				current: 0,
			}
		},
		onLoad(e) {
			this.type = e.type
			this.current = e.type - 1
			this.loadData()
		},
		methods: {
			// 交易列表展示
			async loadData() {
				uni.showLoading({
					title: '加载中'
				});
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Datas/getProductActiveTotalData',
					data: {
						type: this.type
					},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					uni.hideLoading()
					this.data = res.data
				} else {
					uni.showToast({
						title: res.msg,
						duration: 1000,
						icon: "none"
					});
				}
			},
			_change(e) {
				this.type = e.type
				this.loadData()
			},
			data_detailed(id, name) {
				uni.navigateTo({
					url: '/pages/version5/data/active/data_detailed?id=' + id + '&name=' + name
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.screen_time {
		padding: 30rpx 30rpx 0 30rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;

		view {
			flex: 0 !important;
		}

		.screen_- {
			margin: 0 40rpx;
		}

		text {
			border: #f9f9f9 1px solid;
			padding: 10rpx 20rpx;
			color: #888888;
		}

		.order {
			margin-left: 30rpx;
			border: none;
			color: #333;
		}
	}

	.data_info_box {
		padding: 30rpx;

		.data_info_title {
			display: flex;
			justify-content: flex-end;
			width: 100%;
		}

		.data_info_list {
			.time {
				font-size: 28rpx;
				color: #666666;
			}

			.data_info {
				margin: 15rpx 0 30rpx 0;
				border-radius: 15rpx;
				box-shadow: 7px 0px 30px -18px #888888;
				display: flex;
				flex-direction: column;

				.data_info_tit {
					display: flex;
					flex-direction: column;
					padding: 30rpx;
					padding-bottom: 0;
					box-sizing: border-box;
					// border-bottom: #eee 1px solid;
					// margin-bottom: 30rpx;

					text {
						font-size: 28rpx;
						color: #666666;
						border-bottom: #eee 1px solid;
						padding-bottom: 10rpx;
					}

					h3 {
						font-weight: 600;
						font-size: 32rpx;
						border-bottom: #eee 1px solid;
						padding-bottom: 20rpx;
						margin-bottom: 20rpx;
					}
				}

				.data_info_end {
					display: flex;
					flex-direction: column;
					padding: 0 30rpx;
					margin-bottom: 20rpx;
					box-sizing: border-box;

					text {
						font-size: 28rpx;
						color: #333;
					}

					.blue_y {
						font-size: 32rpx;
						color: #1792ff;
						font-weight: 600;
					}

					.gray_y {
						color: #333;
					}

					.border_box {
						display: flex;
						justify-content: space-between;
						align-items: center;
						padding: 20rpx 0;
						border-bottom: #eee 1px solid;

						view {
							display: flex;
							align-items: center;
						}
					}
				}

				.data_info_end:last-child {

					.border_box {
						border-bottom: none;
						padding-bottom: 0;
					}
				}
			}
		}
	}
</style>